//引脚定义
const int trig = 8;
const int echo= 9;
void setup() {
  // put your setup code here, to run once:
pinMode(trig,OUTPUT);
pinMode(echo,INPUT);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int t1;
  float distance;
  digitalWrite(trig,HIGH);
  delayMicroseconds(10);
  digitalWrite(trig,LOW);
  t1 = pulseIn(echo, HIGH);
  distance = t1 / 58;
  Serial.println(distance);
  t1 = 0;
  distance = 0;
  delay(500);
}
